package com.zly.framework.rbac.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import java.io.Serial;

/**
 * @author 钟刘扬
 */
@EqualsAndHashCode(callSuper = true)
@Data
@ToString(callSuper = true)
@Accessors(chain = true)
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "sys_user_role")
@TableName("sys_user_role")
@Schema(name = "用户角色")
public class UserRole extends BaseEntity {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "角色ID")
    @Column(name = "role_id")
    private Long roleId;

    @Schema(description = "用户ID")
    @Column(name = "user_id")
    private Long userId;

    @Transient
    @TableField(exist = false)
    @Schema(description = "用户名")
    private String userName;

    @Transient
    @TableField(exist = false)
    @Schema(description = "角色名")
    private String roleName;
}
